//
//  ViewController.m
//  计算器
//
//  Created by 宋 on 16/3/1.
//  Copyright © 2016年 宋. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)method
{
    NSString *text1 = self.textfield1.text;
    NSString *text2 = self.textfield2.text;
    int num1 = [text1 intValue];
    int num2 = [text2 intValue];
//    int result = num1 - num2;
    int result = 0;
    NSString *fu = self.yun.text;
    char ysf = [fu characterAtIndex:0];
    switch (ysf) {
        case '+':
            result = num1 + num2;
            break;
        case '-':
            result = num1 - num2;
            break;
        case 'x':
            result = num1 * num2;
            break;
        case '/':
            result = num1 / num2;
            break;

        default:
            break;
    }
   
    NSString *output = [NSString stringWithFormat:@"%d",result];
    
    self.res.text = output;
    
//    NSLog(@"这个按钮被点击！");
    NSLog(@"%d",result);
    [self.view endEditing:YES];
}

- (IBAction)method1{
self.yun.text = @"+";
}

- (IBAction)method2{
    self.yun.text = @"-";
}


- (IBAction)method3
{
    self.yun.text = @"x";
}

- (IBAction)method4
{
    self.yun.text = @"/";
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
